package com.tsj.spzx.user.service.Impl;

import com.tsj.spzx.model.entity.base.Region;
import com.tsj.spzx.user.mapper.AddressRegionMapper;
import com.tsj.spzx.user.service.AddressRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressRegionServiceImpl implements AddressRegionService {

    @Autowired
    private AddressRegionMapper addressRegionMapper;

    /**
     * 根据 parentCode 查询区域信息
     * @param parentCode
     * @return
     */
    @Cacheable(value = "region", key = "#parentCode")
    @Override
    public List<Region> findByParentCode(String parentCode) {
        List<Region> regionList = addressRegionMapper.findByParentCode(parentCode);
        return regionList;
    }
}
